home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Communications / Internet / TurboTCP 2.1 ƒ / TCL MiniTelnet source / CTerminalPane.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-04  |  3.6 KB  |  136 lines  |  [TEXT/MMCC]

  1. /*
  2. ** CTerminalPane.h
  3. **
  4. **    TerminalPane library
  5. **    Terminal display pane
  6. **
  7. **    Copyright © 1993-94, FrostByte Design / Eric Scouten
  8. **
  9. */
  10.  
  11.  
  12. #pragma once
  13. #include "CPanorama.h"
  14.  
  15.  
  16. /*
  17. ** These constants define the terminal size. You may change them here. With a little
  18. ** work, these parameters could be changed on the fly. But I haven’t been so ambitious. :-P
  19. */
  20.  
  21. #define maxX                80                    // width of screen
  22. #define maxY                24                    // height of screen
  23.  
  24. #define pixelsX                6                    // default font char width (Monaco 9)
  25. #define pixelsY                11                    // default font char height
  26.  
  27. #define offsetX                4                    // horizontal offset from screen edge
  28. #define offsetY                4                    // vertical offset from screen edge
  29.  
  30. #define sizeX                488                    // 80 columns * 6 pixels + 8 margin
  31. #define sizeY                272                    // 24 rows * 11 pixels + 8 margin
  32.  
  33.  
  34. // define the characters we will recognize
  35.  
  36. #ifndef _ASCII
  37. enum {                                        // standard ASCII keycodes
  38.     charNUL = 0,
  39.     charBEL = 7,
  40.     charBS,
  41.     charHT,
  42.     charLF,
  43.     charVT,
  44.     charFF,
  45.     charCR,
  46.     charDEL = 127
  47. };
  48. #define _ASCII 1
  49. #endif
  50.  
  51.  
  52. /*______________________________________________________________________
  53. **
  54. ** CTerminalPane
  55. **
  56. **    This class provides a rudimentary terminal emulator. It’s nothing fancy or snazzy.
  57. **    It doesn’t do VT100; it doesn’t do scrollback; it doesn’t handle any kind of formatting.
  58. **
  59. */
  60.  
  61. class CTerminalPane : public CPanorama {
  62.  
  63.     TCL_DECLARE_CLASS;
  64.  
  65. protected:
  66.     char            theScreen[maxY][maxX];            // contents of the screen
  67.     short        theColumn;                    // terminal cursor column number
  68.     short        theLine;                        // terminal cursor line number
  69.     Boolean        blinkCursor;                    // cursor blinking is enabled
  70.     Boolean        cursorVis;                    // cursor is inverted
  71.     Boolean        disableKeyScroll;                // disable Home/End/PageUp/PageDown
  72.     short        lastCursorCol;                    // position of displayed cursor
  73.     short        lastCursorLine;
  74.     long            lastCursorTick;                    // time at last cursor flash
  75.     short        charsToInvalLine;                // trigger optimization to invalidate entire line at once
  76.  
  77.     
  78.     // contructors
  79.     
  80. public:
  81.                 CTerminalPane();
  82.                 CTerminalPane(CView* anEnclosure, CBureaucrat* aSupervisor,
  83.                             short aWidth = 0, short aHeight = 0,
  84.                             short aHEncl = 0, short aVEncl = 0,
  85.                             SizingOption aHSizing = sizELASTIC,
  86.                             SizingOption aVSizing = sizELASTIC);
  87.     void            ITerminalPane(CView* anEnclosure, CBureaucrat* aSupervisor,
  88.                             short aWidth, short aHeight, short aHEncl, short aVEncl,
  89.                             SizingOption aHSizing, SizingOption aVSizing);
  90. private:
  91.     void            CTerminalPaneX();
  92.  
  93.     // drawing
  94.     
  95. public:
  96.     virtual void    Draw(Rect* area);
  97.     
  98.     
  99.     // blinking cursor support
  100.     
  101.     virtual void    Dawdle(long* maxSleep);
  102.     virtual Boolean    BecomeGopher(Boolean fBecoming);
  103.     virtual void    SetBlinking(Boolean blinkMode);
  104.  
  105.  
  106.     // scrolling
  107.     
  108.     virtual void    ScrollToSelection();
  109.     virtual void    DisableKeyScroll(Boolean disable);
  110.     virtual void    DoKeyDown(char theChar, Byte keyCode, EventRecord* macEvent);
  111.     
  112.     
  113.     // terminal emulation methods
  114.     
  115.     virtual void    DoClearScreen();
  116.     virtual void    DoWriteChar(char theChar);
  117.     virtual void    DoWriteStr(char* theStr);
  118.     virtual void    DoWriteBfr(char* theStr, short theSize);
  119.     virtual void    DoWriteCharNum(char theChar, char leftBracket, char rightBracket);
  120.     virtual void    DoEraseChar();
  121.     virtual void    DoEraseLine();
  122.     
  123.     
  124.     // private screen handling methods
  125.     
  126. protected:
  127.     virtual void    ClearToEOL(short col, short line);
  128.     virtual void    ClearToEOS(short col, short line);
  129.     virtual void    ScrollTerm();
  130.     virtual void    InvalCharRect(short left, short top, short right, short bottom);
  131.     virtual void    CursorMoved();
  132.     virtual void    CalcCharRect(short left, short top, short right, short bottom, LongRect* theRect);
  133.     virtual void    InvertCursor(short col, short line);
  134.  
  135. };
  136.